<%@page import="Cl.MemoBean"%>
<%@page import="Cl.MemoCl"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'MyJsp.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<style type="text/css">
		a {text-decoration:none; }
		a:link {color: #000000}     /* 未访问的链接 */
		a:visited {color: #000000}  /* 已访问的链接 */
		a:hover {color: #000000}    /* 当有鼠标悬停在链接上 */
		a:active {color: #000000}   /* 被选择的链接 */
	</style>
  </head>
  
  <body>
    <a href = "index.jsp">aa</a>
    <%
    	String id = request.getParameter("tid");
    	String name = "";
    	String email = "";
    	String tel = "";
    	String remark = "";
    	if(id!=null && !id.equals("0"))
    	{
    		MemoCl op = new MemoCl();
    		MemoBean tmp = op.getMemoById(id);
    		name = tmp.getName();
    		email = tmp.getEmail();
    		tel = tmp.getTel();
    		remark = tmp.getRemark();
    	}
    %>
    <form action = "CL.jsp?do=au&&tid=<%=id %>" method = "post" onsubmit="return check()">
    	<table>
    		<tr>
    			<td>姓 名</td> <td> <input type = "text" value = "<%=name%>" name = "nm"> </td>
    		</tr>
    		<tr>
    			<td>电 话</td> <td> <input type = "text" value = "<%=tel%>" name = "tl" id = "tl" onblur="cc(1)"> </td>
    			<td><input type = "text" id = "tll" style="visibility:hidden;border:none"></td>
    		</tr>
    		<tr>
    			<td>Email</td> <td> <input type = "text" value = "<%=email%>" name = "el" id = "el" onblur="cc(2)"> </td>
    			<td><input type = "text" id = "ell" style="visibility:hidden;border:none"></td>
    		</tr>
    		<tr>
    			<td>备 注</td> <td> <input type = "text" value = "<%=remark%>" name = "mk"> </td>
    		</tr>
    	</table>
    	<input type = "reset" value = "重置">
    	<input type = "submit" value = "添加">
    </form>
  </body>
    <script>
	    function check()
	    {
	    	if(cc(1) && cc(2))
	    		return true;
	    	return false;
	    }
	    function cc(x)
	    {
	    	if(x == 1)
	    	{
		    	var tel = document.getElementById("tl").value;
		    	var re = /\d{11}|\d{7}/;
		    	var tt = document.getElementById("tll");
		    	if(tel == "")
		    	{
		    		tt.value = "号码不能为空";
		    		document.getElementById("tll").style.visibility="visible";
		    		return false;
		    	}
		    	else if(!re.test(tel))
		    	{
		    		tt.value = "号码不合法";
		    		tt.style.visibility="visible";
		    		return false;
		    	}
		    	tt.style.visibility="hidden";
		    	return true;
	    	}
	    	else
	    	{
	    		var re =  /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
	    		var mm = document.getElementById("el").value;
	    		var tt = document.getElementById("ell");
	    		//alert(mm != "");
	    		//alert();
	    		
	    		if(mm != "" && !re.test(mm))
	    		{
	    			tt.value = "E-mail不合法";
		    		tt.style.visibility="visible";
		    		return false;
	    		}
	    		tt.value = "";
	    		tt.style.visibility="hidden";
	    		return true;
	    	}
	    }
	    
  	</script>
</html>
